/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elsimulatorjava;

import java.util.ArrayList;

/**
 *
 * @author corey
 */
public class ElevatorDialog {
  /*  private QTableWidget tableWidget;
    private QTableView tableView;
    private QPushButton autoFillB, submitB;

    private ArrayList<Elevator> elevators = new ArrayList<Elevator>();

    private int numOfElevators, maxFloor;

    ElevatorDialog(int nE, int mF){
        this.numOfElevators = nE;
        this.maxFloor = mF;
        this.setWindowTitle("Elevator set up");
        ArrayList<String> verticalLabels = new ArrayList();
        ArrayList<String> horizontalLabels = new ArrayList();
        
        horizontalLabels.add("Minimum Floor");
        horizontalLabels.add("Maximum Floor");
        horizontalLabels.add("Avoid Floor(s)");

        this.autoFillB = new QPushButton();
        this.submitB = new QPushButton();

        this.autoFillB.setText("Auto Fill");
        this.submitB.setText("Set Elevator(s)");
        this.submitB.setDefault(true);

        this.submitB.clicked.connect(this, "submitClicked()");

        for (int i = 0; i < this.numOfElevators; i++){
            verticalLabels.add(String.valueOf(i));
        }

        QGridLayout dialogGridLayout = new QGridLayout();

        this.tableWidget = new QTableWidget(this.numOfElevators, 3, this);
        for (int i = 0; i < this.numOfElevators; i++){
            this.tableWidget.setItem(i, 0, new QTableWidgetItem("0"));
            this.tableWidget.setItem(i, 1, new QTableWidgetItem(String.valueOf(this.maxFloor)));
            this.tableWidget.setItem(i, 2, new QTableWidgetItem(""));
        }
        this.tableWidget.setHorizontalHeaderLabels(null);
        this.tableWidget.setHorizontalHeaderLabels(horizontalLabels);
        this.tableWidget.setVerticalHeaderLabels(verticalLabels);

        dialogGridLayout.addWidget(tableWidget, 0, 0, 1, 0);
        dialogGridLayout.addWidget(submitB, 1, 1);
        this.setLayout(dialogGridLayout);
        this.setFixedSize(350, 300);
    }

    void submitClicked(){
        Boolean close = true;
        this.generateElevators();
        for (int i = 0; i < this.numOfElevators; i++){
            if (this.tableWidget.item(i, 0).text().isEmpty() || this.tableWidget.item(i, 1).text().isEmpty()){
                close = false;
            }
        }
            if (close){
                this.close();
            } else {
                QMessageBox msgBox = new QMessageBox();
                msgBox.setText("You must fill all required fields.");
                msgBox.setIcon(QMessageBox.Icon.Warning);
                msgBox.exec();
            }
    }

    void generateElevators(){
        elevators = new ArrayList<Elevator>();
        ArrayList<Boolean> bl = new ArrayList<Boolean>();
        
        for (int i = 0; i < this.numOfElevators; i++){
            String banlist[];
            
                banlist = this.tableWidget.item(i, 2).text().split(" ");
                for (int j = 0; j < this.maxFloor ; j++){
                    Boolean banlisted = false;
                    if (!this.tableWidget.item(i, 2).text().isEmpty()){
                        for (int k = 0; k < banlist.length; k++){
                            if (j == Integer.parseInt(banlist[k])){
                                banlisted = true;
                            }
                        }
                    }

                    if (banlisted){
                        bl.add(false);
                    } else{
                        bl.add(true);
                    }

                }

        }
        for (int i = 0; i < this.numOfElevators; i++){
            elevators.add(new Elevator(Integer.parseInt(this.tableWidget.item(i, 0).text()), Integer.parseInt(this.tableWidget.item(i, 1).text()), bl));
        }
    }

    ArrayList<Elevator> getElevators(){
        return elevators;
    }

    @Override
    protected void keyPressEvent(QKeyEvent e){
        if (e.key() != Qt.Key.Key_Escape.value()){
            super.keyPressEvent(e);
        }
    }*/
}
